package com.mj.listen2._01_排序;

import com.mj.listen2._01_排序.tools.Asserts;
import com.mj.listen2._01_排序.tools.Integers;
import com.mj.listen2._01_排序.cmp.*;

import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Integer[] array = Integers.random(100000, 1, 100000);
//        Integer[] array = {7, 3, 5, 18, 27, 4, 5};
        testSorts(array,
//                  new _10_RadixSort()
//                  new _09_CountingSort2()
//                new _09_CountingSort()
//                new _01_BubbleSort3<Integer>(),
//                new _02_SelectSort<Integer>(),
//                new _03_HeapSort<Integer>(),
//                new _04_InsertSort<Integer>(),
                new _05_InsertSort<Integer>(),
                new _06_MergeSort<Integer>(),
//                new _07_QuickSort1<Integer>(),
                new _07_QuickSort2<Integer>(),
                new _07_QuickSort3<Integer>(),
                new _08_HillSort<Integer>()
        );
    }

    // 下面这个复制就可以
    static void testSorts(Integer[] array, Sort... sorts) {
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray));
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }
}
